<?php

class admin_model_content_category extends model
{
    
    /**
     * 获取分类列表
     */
	public function get_categories()
	{
		$db = bone::get_db();
		return $db->get_objs( 'SELECT * FROM `bone_content_category` ORDER BY `ordering` ASC' );
	}
    
	
	/**
	 * 删除菜单分类
	 * @param int $category_id 分类编号
	 */
	public function delete( $category_id )
	{
		$db = bone::get_db();
		$db->execute( 'UPDATE `bone_content_article` SET `category_id`=0 WHERE `category_id`='.$category_id );
		$db->execute( 'UPDATE `bone_content_category` SET `parent_id`=0 WHERE `parent_id`='.$category_id );
		$db->execute( 'DELETE FROM `bone_content_category` WHERE `id`='.$category_id );
	}



}
?>